#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int d[N],v[N],a[N],pos[N],ch[N],pai[N];
bool cnt[N][N];
bool check(int x){
    //???
    return 1;
}
void solve(){
    int n,m,L,V,ans1=0,ans2=0;
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>pos[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(pos[j]>=d[i]){
                if(1ll*v[i]*v[i]+2*a[i]*(pos[j]-d[i])>1ll*V*V)cnt[i][j]=1;
                else cnt[i][j]=0;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(cnt[i][j]==1){
            ch[i]=1;
            continue;
        }
    }
}
    for(int i=1;i<=n;i++){
        if(ch[i]==1)ans1++;
    }
    cout<<ans1<<" ";
    for(int j=1;j<=m;j++){
        for(int i=1;i<=n;i++){
            if(cnt[i][j]==1){
            pai[j]++;
            continue;
        }
    }
}
    if(ans1==0){
    cout<<m<<endl;
    return;
    }
    int l=1,r=ans1;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid)){
            ans2=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    cout<<m-ans2<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;cin>>t;
    while(t--)solve();
    return 0;
}
